<template>
	<view class="money_report">
		<view class="head">
			<view class="time">
				<view class="icon" @click="$refs.calendar.open();">
					<u-icon name="arrow-down-fill" labelPos="left" :label="timerange" color="#999999" labelSize="10"
						size="13"></u-icon>
				</view>
				<view style="display: flex;">
					<uni-calendar ref="calendar" class="uni-calendar--hook" :clear-date="true" :insert="info.insert"
						:lunar="info.lunar" :range="info.range" @confirm="confirm" />
				</view>
			</view>
			<view class="report">
				<view class="total_revenue">
					总收入￥0.00
				</view>
				<view class="total_expenditure">
					总支出￥0.00
				</view>
			</view>

		</view>
		<u-sticky bgColor="#fff">
			<u-tabs :list="tabs" lineColor="#ffa303" :scrollable="false" @click="click"></u-tabs>
		</u-sticky>
		<view class="content" v-if="dataList.length>0">
			<view class="" v-for="(item,index) in dataList" :key="index">
				{{item}}
			</view>
		</view>
	</view>
</template>

<script>
	let date = new Date();
	let year = date.getFullYear();
	let month = date.getMonth() + 1;
	let day = date.getDate();
	export default {
		props:{
			dataList:{
				type:Array,
				default:()=>[]
			}
		},
		data() {
			return {
				info: {
					lunar: true,
					range: true,
					insert: false,
					selected: []
				},
				timerange: year + "-" + month + "-" + day,
				//tab数据
				tabs: [{
					name: '全部',
				}, {
					name: '收入',
				}, {
					name: '支出'
				}],
			}
		},
		methods: {
			click(item) {
				this.$emit("changeTab",item.index)
			},
			confirm(e) {
				if (e.range.before == "" || e.range.after == "") {
					this.timerange = e.fulldate
				} else {
					this.timerange = e.range.before + "~" + e.range.after
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.money_report {
		background-color: #F6F6F6;
	}

	.head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;

		.time {
			padding: 10rpx 20rpx;
			border-radius: 30rpx;
			background-color: #fff;
		}

		.report {
			color: #a2a2a2;
			font-size: 24rpx;
		}
	}

	.uni-calendar--hook {
		z-index: 99999;
	}
</style>